package service.impl;


import dao.GdUserArticlelistMapper;
import org.springframework.stereotype.Service;
import service.GdUserArticlelistService;

import javax.annotation.Resource;

@Service
public class GdUserArticlelistServiceImpl implements GdUserArticlelistService {
    @Resource
    private GdUserArticlelistMapper gdUserArticlelistMapper;

    /**
     * 收藏文章
     * @param userId
     * @param articleId
     * @return
     */
    @Override
    public boolean insert(Long userId, Long articleId) {
        return gdUserArticlelistMapper.insert(userId,articleId)>0;
    }

    /**
     * 取消收藏
     * @param articleId
     * @return
     */
    @Override
    public boolean delete(Long userId,Long articleId) {
        return gdUserArticlelistMapper.delete(userId,articleId)>0;
    }

    /**
     * 判断文章是否已收藏
     * @param articleId
     * @param userId
     * @return
     * @throws Exception
     */
    @Override
    public boolean isFavorite(Long articleId, Long userId) throws Exception {
        return gdUserArticlelistMapper.isFavorite(articleId, userId)!=null;
    }

}